<template>
  <div class="grad-container">
    <h3>分润配置</h3>
    <el-form ref="formRef" :model="form" :rules="formRules" label-width="170px">
      <el-form-item label="直推奖" prop="pushStraight">
        <el-input-number v-model="form.pushStraight" :min="0" :step="0.01" placeholder="请输入"></el-input-number>
        <span class="mlr">%</span>
        <span>*订单商品贡献值百分比，分润为贡献值</span>
      </el-form-item>
      <!-- <el-form-item label="间推分润" prop="pushBetween">
        <el-input-number
          v-model="form.pushBetween"
          :min="0"
          :step="0.01"
          placeholder="请输入"
        ></el-input-number>
        <span class="mlr">%</span>
        <span>*订单实付金额百分比，分润为贡献值</span>
      </el-form-item> -->
      <el-form-item label="联创分红" prop="headOfGroup">
        <el-input-number v-model="form.headOfGroup" :min="0" :step="0.01" placeholder="请输入"></el-input-number>
        <span class="mlr">%</span>
        <span>*订单商品贡献值百分比，分润为贡献值</span>
      </el-form-item>
      <el-form-item label="核销订单奖励" prop="headOfGroup">
        <el-input-number v-model="form.consumerDirectPushReward" :min="0" :step="0.01" placeholder="请输入"></el-input-number>
        <span class="mlr">%</span>
        <span>*订单商品贡献值百分比，分润为贡献值</span>
      </el-form-item>
      <el-form-item label="平级奖励" prop="interimHead">
        <el-input-number v-model="form.interimHead" :min="0" :step="0.01" placeholder="请输入"></el-input-number>
        <span class="mlr">%</span>
        <span>*分润为贡献值</span>
      </el-form-item>
      <!-- <el-form-item label="属地分润" prop="territorial">
        <el-input-number v-model="form.territorial" :min="0" :step="0.01" placeholder="请输入"></el-input-number>
        <span class="mlr">%</span>
        <span>*订单商品贡献值百分比，分润为实际货币</span>
      </el-form-item> -->

      <el-form-item label="平级奖励代数" prop="territorial">
        <el-input-number v-model="form.territorial" :min="0" placeholder="请输入"></el-input-number>
<!--        <span class="mlr">%</span>-->
<!--        <span>*订单贡献值百分比，分润为贡献值</span>-->
      </el-form-item>
      <hr/>
<!--      <el-form-item label="消费者直推奖励" prop="consumerDirectPushReward">-->
<!--        <el-input-number v-model="form.consumerDirectPushReward" :min="0" :step="0.01" placeholder="请输入"></el-input-number>-->
<!--        <span class="mlr">%</span>-->
<!--        <span>*打赏积分百分比，分润为积分</span>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="商家直推奖励" prop="shopDirectPushReward">-->
<!--        <el-input-number v-model="form.shopDirectPushReward" :min="0" :step="0.01" placeholder="请输入"></el-input-number>-->
<!--        <span class="mlr">%</span>-->
<!--        <span>*打赏积分百分比，分润为积分</span>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="消费者团长奖励" prop="consumerRegimentReward">-->
<!--        <el-input-number v-model="form.consumerRegimentReward" :min="0" :step="0.01" placeholder="请输入"></el-input-number>-->
<!--        <span class="mlr">%</span>-->
<!--        <span>*打赏积分百分比，分润为积分</span>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="商家团长奖励" prop="shopRegimentReward">-->
<!--        <el-input-number v-model="form.shopRegimentReward" :min="0" :step="0.01" placeholder="请输入"></el-input-number>-->
<!--        <span class="mlr">%</span>-->
<!--        <span>*打赏积分百分比，分润为积分</span>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="消费者间推团长奖励" prop="consumerInterpositionRegimentReward">-->
<!--        <span>团长分润所得的</span>-->
<!--        <el-input-number v-model="form.consumerInterpositionRegimentReward" :min="0" :step="0.01" placeholder="请输入"></el-input-number>-->
<!--        <span class="mlr">%</span>-->
<!--        <span>*打赏积分百分比，分润为积分</span>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="商家间推团长奖励" prop="shopInterpositionRegimentReward">-->
<!--        <span>团长分润所得的</span>-->
<!--        <el-input-number v-model="form.shopInterpositionRegimentReward" :min="0" :step="0.01" placeholder="请输入"></el-input-number>-->
<!--        <span class="mlr">%</span>-->
<!--        <span>*打赏积分百分比，分润为积分</span>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="消费者属地分润奖励" prop="consumerTerritorialReward">-->
<!--        <el-input-number v-model="form.consumerTerritorialReward" :min="0" :step="0.01" placeholder="请输入"></el-input-number>-->
<!--        <span class="mlr">%</span>-->
<!--        <span>*打赏积分百分比，分润为积分，以消费者直推线往上找到第一个区县运营中心分润，没有不部分</span>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="商家属地分润奖励" prop="shopTerritorialReward">-->
<!--        <el-input-number v-model="form.shopTerritorialReward" :min="0" :step="0.01" placeholder="请输入"></el-input-number>-->
<!--        <span class="mlr">%</span>-->
<!--        <span>*打赏积分百分比，分润为积分，以商家所在区县找区县运营中心分润，没有则不分</span>-->
<!--      </el-form-item>-->
<!--       <hr/>-->
<!--      <el-form-item label="线下订单消费者贡献值" prop="offlineOrderConsumerContribute">-->
<!--        <el-input-number v-model="form.offlineOrderConsumerContribute" :min="0" :step="0.01" placeholder="请输入"></el-input-number>-->
<!--        <span class="mlr"></span>-->
<!--        <span>*打赏金额的倍数，即为消费者可以获取的贡献值</span>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="线下订单商家贡献值" prop="offlineOrderShopContribute">-->
<!--        <el-input-number v-model="form.offlineOrderShopContribute" :min="0" :step="0.01" placeholder="请输入"></el-input-number>-->
<!--        <span class="mlr"></span>-->
<!--        <span>*打赏金额的倍数，即为商家可以获取的贡献值</span>-->
<!--      </el-form-item>-->
<!--      <hr />-->
<!--        <h4>福利区订单分润配置</h4>-->
<!--        <el-form-item label="直推分润" prop="welfarePushStraight">-->
<!--          <el-input-number v-model="form.welfarePushStraight" :min="0" :step="0.01" placeholder="请输入"></el-input-number>-->
<!--          <span class="mlr">%</span>-->
<!--          <span>*订单金额百分比，分润为金额</span>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="团长分润" prop="welfareHeadOfGroup">-->
<!--          <el-input-number v-model="form.welfareHeadOfGroup" :min="0" :step="0.01" placeholder="请输入"></el-input-number>-->
<!--          <span class="mlr">%</span>-->
<!--          <span>*订单金额百分比，分润为金额</span>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="间推团长分润" prop="welfareInterimHead">-->
<!--          <span>团长分润所得的</span>-->
<!--          <el-input-number v-model="form.welfareInterimHead" :min="0" :step="0.01" placeholder="请输入"></el-input-number>-->
<!--          <span class="mlr">%</span>-->
<!--          <span>*分润为金额</span>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="线上订单属地分润" prop="welfareTerritorial">-->
<!--          <el-input-number v-model="form.welfareTerritorial" :min="0" :step="0.01" placeholder="请输入"></el-input-number>-->
<!--          <span class="mlr">%</span>-->
<!--          <span>*订单金额百分比，分润为金额</span>-->
<!--        </el-form-item>-->
      <el-form-item>
        <el-button type="primary" @click="saveForm()">保存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import seviceApi from '@/api/serviceApi.js'
export default {
  data () {
    return {
      form: {},
      formRules: {
        pushStraight: {
          required: true,
          message: '直推分润不能为空',
          trigger: 'blur'
        },
        pushBetween: {
          required: true,
          message: '间推分润不能为空',
          trigger: 'blur'
        },
        headOfGroup: {
          required: true,
          message: '团长分润不能为空',
          trigger: 'blur'
        },
        interimHead: {
          required: true,
          message: '间推团长分润不能为空',
          trigger: 'blur'
        },
        territorial: {
          required: true,
          message: '属地分润不能为空',
          trigger: 'blur'
        },

        consumerDirectPushReward: {
          required: true,
          message: '消费者直推奖励不能为空',
          trigger: 'blur'
        },
        shopDirectPushReward: {
          required: true,
          message: '商家直推奖励不能为空',
          trigger: 'blur'
        },
        consumerRegimentReward: {
          required: true,
          message: '消费者团长奖励不能为空',
          trigger: 'blur'
        },
        shopRegimentReward: {
          required: true,
          message: '商家团长奖励不能为空',
          trigger: 'blur'
        },
        consumerInterpositionRegimentReward: {
          required: true,
          message: '消费者间推团长奖励不能为空',
          trigger: 'blur'
        },
        shopInterpositionRegimentReward: {
          required: true,
          message: '商家间推团长奖励不能为空',
          trigger: 'blur'
        },
        consumerTerritorialReward: {
          required: true,
          message: '消费者属地分润奖励不能为空',
          trigger: 'blur'
        },
        shopTerritorialReward: {
          required: true,
          message: '商家属地分润奖励不能为空',
          trigger: 'blur'
        },
        offlineOrderConsumerContribute: {
          required: true,
          message: '线下订单消费者贡献值不能为空',
          trigger: 'blur'
        },
        offlineOrderShopContribute: {
          required: true,
          message: '线下订单商家贡献值不能为空',
          trigger: 'blur'
        },
        welfarePushStraight:{
          required: true,
          message: '直推分润不能为空',
          trigger: 'blur'
        },
        welfareHeadOfGroup:{
          required: true,
          message: '团长分润不能为空',
          trigger: 'blur'
        },
        welfareInterimHead:{
          required: true,
          message: '间推团长分润不能为空',
          trigger: 'blur'
        },
        welfareTerritorial:{
          required: true,
          message: '线上订单属地分润不能为空',
          trigger: 'blur'
        }
      }
    }
  },
  created () {
    this.getInfo()
  },
  methods: {
    getInfo () {
      seviceApi.getDivideInfo().then(res => {
        if (res && res.data.code == 200) {
          this.form = res.data.data
        }
      })
    },
    saveForm () {
      this.$refs.formRef.validate(valid => {
        if (valid) {
          seviceApi.saveDivide(this.form).then(res => {
            if (res && res.data.code == 200) {
              this.getInfo()
              this.$message.success('保存成功')
            }
          })
        } else {
          this.$message.error('请将表单补充完整')
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.grad-container {
  /deep/ .el-form {
    .el-form-item__label {
      font-weight: bold;
    }

    .el-input {
      width: 300px;
    }

    .el-input-number--medium {
      width: 300px;
    }

    .mlr {
      margin-left: 20px;
      margin-right: 20px;
    }
  }
}
</style>
